<admintpl file="header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('Report/index')}">充值记录</a></li>
			<li><a  href="{:U('Report/retrieval')}">订单统计</a></li>
			<li  class="active"><a>放款统计</a></li>
			<li><a href="{:U('Report/member')}">会员统计</a></li>
			<li><a href="{:U('Report/loan_census')}">下款统计</a></li>
		</ul>
		<form class="well form-search" method="post" action="">
			类型：<select name="timer_type">
				<php>$tpl_selected=I('request.timer_type')=='1'?"selected":"";</php>
				<option {$tpl_selected} value="1">自然日</option>
				<php>$tpl_selected=I('request.timer_type')=='2'?"selected":"";</php>
				<option {$tpl_selected} value="2">自然周</option>
				<php>$tpl_selected=I('request.timer_type')=='3'?"selected":"";</php>
				<option {$tpl_selected} value="3">自然月</option>
				</select>
			时间：<input class="js-date" type="text" name="starts" style="width: 200px;" value="{:I('request.starts',date('Y-m-d'))}" placeholder="起始时间">
			<input class="js-date" type="text" name="ends" style="width: 200px;" value="{:I('request.ends',date('Y-m-d'))}" placeholder="结束时间">
			<input type="submit" class="btn btn-primary" value="搜索" />
			<a class="btn btn-danger" href="">清空</a>
		</form>
		<form method="post" class="js-ajax-form">
			<table class="table table-hover table-bordered">
				<thead>
					<tr>					
						<th>时间</th>
						
						<th>初次<br/>借款金额</th>
						<th>初次<br/>放款本金</th>

						<th>初次<br/>总服务费</th>
						

						<th>续借<br/>借款金额</th>
						<th>续借<br/>放款本金</th>

						<th>续借<br/>总服务费</th>
						<th>初次<br/>已收<br/>总服务费</th>
						<th>续借<br/>已收<br/>总服务费</th>

						<th>总<br/>已收<br/>服务费</th>

						<th>当日<br/>应收<br/>还款金额</th>
						
						<th>当日<br/>应收<br/>逾期费</th>
						<th>当日<br/>实收<br/>续期费</th>
						
						
						<th>当日<br/>实收<br/>还款金额</th>
						<th>当日<br/>实收<br/>逾期费</th>
						
						<th>微信<br/>实收</th>
						<th>支付宝<br/>实收</th>
						<th>银行<br/>实收</th>
						<th>初次<br/>放款次数</th>
						<th>续借<br/>放款次数</th>
						
						<th>放款人</th>
						
						
					</tr>
				</thead>
				<tbody>
					<foreach name="list" item="vo">
					<tr>
						<td align="center">{$vo.thedate_time}</td>
						
						<td align="center">{$vo.total_amount|default=""}</td>
						<td align="center">{$vo.fang_amount|default=""}</td>

						<td align="center">{$vo['interest']+$vo['examine']+$vo['consulting']}</td>
						

						<td align="center">{$vo.xu_total_amount|default=""}</td>
						<td align="center">{$vo.xu_fang_amount|default=""}</td>

						<td align="center">{$vo['xu_interest']+$vo['xu_examine']+$vo['xu_consulting']}</td>
						
						<td align="center">{$vo['chu_paid_services']|default=""}</td>
						<td align="center">{$vo['xu_paid_services']|default=""}</td>
						<td align="center">{$vo['chu_paid_services']+$vo['xu_paid_services']}</td>

						<td align="center">{$vo['y_amount']+$vo['order_amount']}</td>
						
						<td align="center">{$vo.yuqi_amount|default=""}</td>
						<td align="center">{$vo.xuqi_amount|default=""}</td>
						
						<td align="center">{$vo['real_amount0']+$vo['real_amount1']+$vo['real_amount2']+$vo['real_amount3']+$vo['real_amount4']+$vo['real_amount5']}</td>
						<td align="center">{$vo['overdue_amount0']+$vo['overdue_amount1']+$vo['overdue_amount2']+$vo['overdue_amount3']+$vo['overdue_amount4']+$vo['overdue_amount5']}</td>
						
						<td align="center">{$vo['wechat_amount0']+$vo['wechat_amount1']+$vo['wechat_amount2']+$vo['wechat_amount3']+$vo['wechat_amount4']+$vo['wechat_amount5']}</td>
						<td align="center">{$vo['alipay_amount0']+$vo['alipay_amount1']+$vo['alipay_amount2']+$vo['alipay_amount3']+$vo['alipay_amount4']+$vo['alipay_amount5']}</td>
						<td align="center">{$vo['bank_amount0']+$vo['bank_amount1']+$vo['bank_amount2']+$vo['bank_amount3']+$vo['bank_amount4']+$vo['bank_amount5']}</td>
						<td align="center">{$vo['chu_num']|default=""}</td>
						<td align="center">{$vo['xu_num']|default=""}</td>
						
						<td align="center">{$users[$vo['examine_id']]|default='系统'}</td>
						
					</tr>
					</foreach>
				</tbody>
				<tfoot>
				<tr>
					<td>合计：</td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td>{$person_total}人</td>
				</tr>
				</tfoot>
			</table>
		</form>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script>
        $(function () {
            var arr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19];//要取哪几列的合计
            var def = 'var ';
            for(var a in arr){
                def += ('total'+arr[a]+'=0,');
            }
            def=def.substring(0,def.length-1)+';';
            eval(def);//执行定义
            $('tbody tr').each(function() {
                for(var i in arr){
                    $(this).find('td:eq('+arr[i]+')').each(function(){
                        var tmp = $(this).text();
                        if(tmp === ''){
                            tmp = 0;
                        }
                        eval('total'+arr[i]+'+=parseFloat(tmp);');
                    });
                }
            });
            for(var x in arr){
                $('tfoot tr:eq(0)').find('td:eq('+arr[x]+')').text(eval('total'+arr[x]+'.toFixed(2)'));
            }
        });
	</script>
</body>
</html>